package com.wangc.commons.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * redis key获取工具类
 *
 * @author 刘杰
 * @date 2020/4/21
 */
public class RedisKeyUtils {

    /**
     * 组装redis key
     *
     * @param key
     * @param values
     * @return
     */
    public static String getRedisKey(String key, String... values) {
        if (StringUtils.isBlank(key) || values == null || values.length <= 0) {
            return null;
        }
        String newKey = key;
        for (int i = 0; i < values.length; i++) {
            newKey = newKey.replaceFirst("%s", values[i]);
        }
        return newKey;
    }

}
